//同时发送请求的次数
let ajaxtiems = 0;
export const request = (params) => {
    ajaxtiems++
    //显示加载
    wx.showLoading({
            title: '加载中',
            mask: true
        })
        //定义公共路径baseUrl
    const baseUrl = 'https://api-hmugo-web.itheima.net/api/public/v1'
    return new Promise((resolve, reject) => {
        wx.request({
            ...params,
            url: baseUrl + params.url,
            success: (result) => {
                resolve(result)
            },
            fail: (err) => {
                reject(err)
            },
            complete: () => {
                ajaxtiems--
                // 同时发送的请求完成后
                if (ajaxtiems === 0) {
                    wx.hideLoading();
                }
            }
        })
    })
}